﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace ZhimeiSoft.CharmManager.DOL
{
    public class DBEntityCustomerServiceItem :DBEntityBase
    {
        public override string GetTableName()
        {
            return "CUSTOMERSERVICEITEM";
        }
        public DBEntityCustomerServiceItem()
            : base()
        {
        }
        public DBEntityCustomerServiceItem(DataRow drRow)
        {
            this.CUSTOMERSERVICEITEMID = Convert.ToInt32(drRow[DBEntityCustomerServiceItem.FieldName.CUSTOMERSERVICEITEMID]);
	        this.CSTATUS = drRow[DBEntityCustomerServiceItem.FieldName.CSTATUS].ToString();
	        this.COUNT = Convert.ToInt32(drRow[DBEntityCustomerServiceItem.FieldName.COUNT]);
	        this.CREMAINCOUNT = Convert.ToInt32(drRow[DBEntityCustomerServiceItem.FieldName.CREMAINCOUNT]);
	        this.SERVICEITEMID = Convert.ToInt32(drRow[DBEntityCustomerServiceItem.FieldName.SERVICEITEMID]);
	        this.CUSTOMERID = Convert.ToInt32(drRow[DBEntityCustomerServiceItem.FieldName.CUSTOMERID]);
	        this.CMEMO = drRow[DBEntityCustomerServiceItem.FieldName.CMEMO].ToString();
            object objLastServiceItem = drRow[DBEntityCustomerServiceItem.FieldName.CLASTSERVICETIME];
            if (objLastServiceItem != null && objLastServiceItem != DBNull.Value)
                this.CLASTSERVICETIME = Convert.ToDateTime(objLastServiceItem);

            object objMoney = drRow[DBEntityCustomerServiceItem.FieldName.CTOTALNEEDPAY];
            if (objMoney != null && objMoney != DBNull.Value)
                this.CTOTALNEEDPAY = Convert.ToDecimal(objMoney);
            else
                this.CTOTALNEEDPAY = 0;

	        this.CBUYTIME = Convert.ToDateTime(drRow[DBEntityCustomerServiceItem.FieldName.CBUYTIME]);
	        this.CSERVICESTARTTIME = Convert.ToDateTime(drRow[DBEntityCustomerServiceItem.FieldName.CSERVICESTARTTIME]);
            this.CSERVICEENDTIME = Convert.ToDateTime(drRow[DBEntityCustomerServiceItem.FieldName.CSERVICEENDTIME]);

            #region 服务项目信息
            object obj = drRow[DBEntityServiceItem.FieldName.SNAME];
            if (obj != null && obj != DBNull.Value)
                this.SNAME = obj.ToString();
            
            obj = drRow[DBEntityServiceItem.FieldName.SPRICE];
            if (obj != null && obj != DBNull.Value)
                this.SPRICE = Convert.ToDecimal(obj);

            obj = drRow[DBEntityServiceItem.FieldName.STIMESPAN];
            if (obj != null && obj != DBNull.Value)
                this.STIMESPAN = Convert.ToInt32(obj);

            obj = drRow[DBEntityServiceItem.FieldName.STATE];
            if (obj != null && obj != DBNull.Value)
                this.STATE = obj.ToString();

            obj = drRow[DBEntityServiceItem.FieldName.SCALLBACKFLAG];
            if (obj != null && obj != DBNull.Value)
                this.SCALLBACKFLAG = Convert.ToInt32(obj);

            obj = drRow[DBEntityServiceItem.FieldName.SCALLBACKDAY];
            if (obj != null && obj != DBNull.Value)
                this.SCALLBACKDAYS = Convert.ToInt32(obj);

            obj = drRow[DBEntityServiceItem.FieldName.STARTDATE];
            if (obj != null && obj != DBNull.Value)
                this.STARTDATE = Convert.ToDateTime(obj);

            obj = drRow[DBEntityServiceItem.FieldName.SENDDATE];
            if (obj != null && obj != DBNull.Value)
                this.SENDDATE = Convert.ToDateTime(obj);

            obj = drRow[DBEntityServiceItem.FieldName.SREMARK];
            if (obj != null && obj != DBNull.Value)
                this.SMEMO = obj.ToString();

            obj = drRow[DBEntityServiceItem.FieldName.SAVAILABLEDAYS];
            if (obj != null && obj != DBNull.Value)
                this.SAVAILABLEDAYS = Convert.ToInt32(obj);

            obj = drRow[DBEntityServiceItem.FieldName.SINDEXCODE];
            if (obj != null && obj != DBNull.Value)
                this.SINDEXCODE = obj.ToString();

            obj = drRow[DBEntityServiceItem.FieldName.SCATEGORYID];
            if (obj != null && obj != DBNull.Value)
                this.SCATEGORYID = Convert.ToInt32(obj);

            obj = drRow[DBEntityServiceItem.FieldName.SERVICEITEMCODE];
            if (obj != null && obj != DBNull.Value)
                this.SERVICEITEMCODE = obj.ToString();

            obj = drRow[DBEntityServiceItem.FieldName.SCOUNT];
            if (obj != null && obj != DBNull.Value)
                this.SCOUNT = Convert.ToInt32(obj);

            #endregion
        }
        /// <summary>
        /// 客户服务项目ID
        /// </summary>
        public int CUSTOMERSERVICEITEMID {get; set;}
        /// <summary>
        /// 服务状态 正在服务进行中C0A 、 服务完成 C0E
        /// </summary>
	    public string CSTATUS {get; set;}
        /// <summary>
        /// 服务项目次数
        /// </summary>
	    public int COUNT {get; set;}
        /// <summary>
        /// 剩余服务项目次数
        /// </summary>
	    public int CREMAINCOUNT {get; set;}
        /// <summary>
        /// 服务项目ＩＤ
        /// </summary>
        public int SERVICEITEMID { get; set; }
        /// <summary>
        /// 用户ID
        /// </summary>
	    public int CUSTOMERID {get; set;}
        /// <summary>
        /// 说明
        /// </summary>
	    public string CMEMO {get; set;}
        /// <summary>
        /// 最近一次服务时间
        /// </summary>
        public DateTime CLASTSERVICETIME {get; set;}
        /// <summary>
        /// 服务项目购买时间
        /// </summary>
	    public DateTime CBUYTIME {get; set;}
        /// <summary>
        /// 服务项目开始时间
        /// </summary>
	    public DateTime CSERVICESTARTTIME {get; set;}
        /// <summary>
        /// 服务项目截止时间
        /// </summary>
        public DateTime CSERVICEENDTIME { get; set; }
        /// <summary>
        /// 是否回访标志
        /// </summary>
        public int CALLBACKFLAG { get; set; }
        /// <summary>
        /// 回访天数
        /// </summary>
        public int CALLBACKDAYS { get; set; }

        /// <summary>
        /// 账号余额
        /// </summary>
        public decimal CTOTALNEEDPAY { get; set; }

        #region 服务项目信息

        /// <summary>
        /// 服务项目名称
        /// </summary>
        public string SNAME { get; set; }
        /// <summary>
        /// 服务项目单价
        /// </summary>
        public decimal SPRICE { get; set; }
        /// <summary>
        /// 服务时间，以分钟为单位
        /// </summary>
        public int STIMESPAN { get; set; }
        /// <summary>
        /// 服务项目状态
        /// </summary>
        public string STATE { get; set; }
        /// <summary>
        /// 是否需要回访
        /// </summary>
        public int SCALLBACKFLAG { get; set; }
        /// <summary>
        /// 多少天回访一次
        /// </summary>
        public int SCALLBACKDAYS { get; set; }
        /// <summary>
        /// 服务项目有效期开始时间
        /// </summary>
        public DateTime STARTDATE { get; set; }
        /// <summary>
        /// 服务项目有效期结束时间
        /// </summary>
        public DateTime SENDDATE { get; set; }
        /// <summary>
        /// 服务项目备注
        /// </summary>
        public string SMEMO { get; set; }
        /// <summary>
        /// 有效服务天数
        /// </summary>
        public int SAVAILABLEDAYS { get; set; }
        /// <summary>
        /// 快速定位码
        /// </summary>
        public string SINDEXCODE { get; set; }
        /// <summary>
        /// 服务项目分类ID
        /// </summary>
        public int SCATEGORYID { get; set; }
        /// <summary>
        /// 服务项目编码
        /// </summary>
        public string SERVICEITEMCODE { get; set; }

        /// <summary>
        /// 服务次数
        /// </summary>
        public int SCOUNT { get; set; }
        #endregion

        public static class FieldName
        {
            /// <summary>
            /// 客户服务项目ID
            /// </summary>
            public const string CUSTOMERSERVICEITEMID = "CUSTOMERSERVICEITEMID";
            /// <summary>
            /// 服务状态 正在服务进行中C0A 、 服务完成 C0E
            /// </summary>
	        public const string CSTATUS = "CSTATUS";
            /// <summary>
            /// 服务项目次数
            /// </summary>
	        public const string COUNT = "COUNT";
            /// <summary>
            /// 剩余服务项目次数
            /// </summary>
	        public const string CREMAINCOUNT = "CREMAINCOUNT";
            /// <summary>
            /// 服务项目ID
            /// </summary>
            public const string SERVICEITEMID = "SERVICEITEMID";
            /// <summary>
            /// 用户ID
            /// </summary>
	        public const string CUSTOMERID = "CUSTOMERID";
            /// <summary>
            /// 说明
            /// </summary>
	        public const string CMEMO = "CMEMO";
            /// <summary>
            /// 最近一次服务时间
            /// </summary>
            public const string CLASTSERVICETIME = "CLASTSERVICETIME";
            /// <summary>
            /// 服务项目购买时间
            /// </summary>
            public const string CBUYTIME = "CBUYTIME";
            /// <summary>
            /// 服务项目开始时间
            /// </summary>
            public const string CSERVICESTARTTIME = "CSERVICESTARTTIME";
            /// <summary>
            /// 服务项目截止时间
            /// </summary>
            public const string CSERVICEENDTIME = "CSERVICEENDTIME";
            /// <summary>
            /// 服务次数
            /// </summary>
            public const string SCOUNT = "SCOUNT";

            /// <summary>
            /// 是否回访标志
            /// </summary>
            public const string CALLBACKFLAG = "CALLBACKFLAG";

            /// <summary>
            /// 多少天后回访
            /// </summary>
            public const string CALLBACKDAYS = "CALLBACKDAYS";

            /// <summary>
            /// 账号余额
            /// </summary>
            public const string CTOTALNEEDPAY = "CTOTALNEEDPAY";
        }
        public static class ENUM_CSTATUS
        {
            /// <summary>
            /// 服务进行中C0A
            /// </summary>
            public const string C0A = "C0A";
            /// <summary>
            ///  服务完成 C0E
            /// </summary>
            public const string C0E = "C0E";
            /// <summary>
            /// 服务进行中C0A
            /// </summary>
            public const string C0A_CHINESE = "服务进行中";
            /// <summary>
            /// 服务完成 C0E
            /// </summary>
            public const string C0E_CHINESE = "服务完成";
            /// <summary>
            /// 根据枚举值返回中文
            /// </summary>
            /// <param name="cState">枚举值</param>
            /// <returns>返回中文</returns>
            public static string EnumStrToChineseStr(string cState)
            {
                string[] serchStr = new string[] { C0A, C0E };
                string[] sReturnStr = new string[] { C0A_CHINESE, C0E_CHINESE };
                return DBEntityBase.GetStrReturnStr(cState, serchStr, sReturnStr);
            }
            /// <summary>
            /// 根据中文返回枚举值
            /// </summary>
            /// <param name="chineseStr">中文</param>
            /// <returns>返回枚举字符串</returns>
            public static string ChineseStrToEnumStr(string chineseStr)
            {
                string[] serchStr = new string[] { C0A, C0E };
                string[] sReturnStr = new string[] { C0A_CHINESE, C0E_CHINESE };
                return DBEntityBase.GetStrReturnStr(chineseStr, serchStr, sReturnStr);
            }
        }

    }
}
